package com.study.service.fallback;

import com.study.domain.Product;
import com.study.service.ProductService;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;

/**
 * @author MI
 * @version 1.0
 * @date 2020/10/18 22:10
 */
//FallbackFactory 泛型
@Slf4j
public class ProductServiceFallbackFactory implements FallbackFactory<ProductService> {
    @Override
    public ProductService create(Throwable cause) {

        return new ProductService() {
            @Override
            public Product findByPid(Integer pid) {
                log.error("{}", cause);
                Product product = new Product();
                product.setPid(-100);
                product.setPname("商品微服务调用出现异常了,已经进入到了容错方法中");
                return product;
            }
        };
    }
}
